package com.cosmos.mapdemo;

import android.content.Context;
import android.graphics.drawable.Drawable;

import com.tianditu.android.maps.ItemizedOverlay;
import com.tianditu.android.maps.Overlay;
import com.tianditu.android.maps.OverlayItem;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Leonardo on 2015/7/22.
 */
public class MultipleItemOverlay extends ItemizedOverlay<OverlayItem> implements Overlay.Snappable {
    private List<OverlayItem> itemList;
    private Context context;
    private Drawable marker;

    public MultipleItemOverlay(Drawable marker, Context context) {
        super((boundCenterBottom(marker)));
        this.context = context;
        this.marker = boundCenterBottom(marker);
        this.itemList = new ArrayList<>();
    }

    public void addItem(OverlayItem item) {
        //item.setMarker(marker);
        itemList.add(item);
    }

    public boolean removeItem(OverlayItem item) {
        return itemList.remove(item);
    }

    // 准备数据
    public void populateItemData() {
        populate();
    }

    @Override
    public int size() {
        return itemList.size();
    }

    @Override
    protected OverlayItem createItem(int i) {
        return itemList.get(i);
    }

    @Override
    protected boolean onTap(int i) {
        return super.onTap(i);
    }
}
